import Cookie from './cookie.js'
import Api from  './api.js'
import WApi from  '../wj/api.js'
import Base_api from './Base_api.js';

new Vue({
    el:'#app',
    data(){
        return{
            uinfos:[],
            tag:true,
            food:'',                //想吃什么
            jcrs:'',               //就餐人数
            options: [{
                value: '黄金糕',
            }, {
                value: '双皮奶',
            }, {
                value: '蚵仔煎',
            }, {
                value: '龙须面',
            }, {
                value: '北京烤鸭',
            }],
            value: '',              //地点选择
            activityHot:[],         //火热饭局
            types:[],               //饭局类型
            places:[],              //饭局地点
            imgs:[],                //走马灯图片集
        }
    },
    methods:{
        serach(){
            location.href = './active.html?food='+this.food+'&place='+this.value+'&jcrs='+this.jcrs
        },
        async info () {
            let zh = sessionStorage.getItem("zh")
            let allinfo = await WApi.login()
            for(let i=0;i<allinfo.length;i++){
                if(allinfo[i].zh==zh){
                    this.uinfos=allinfo[i]
                    break
                }
            }
            this.activityHot = Base_api.getactivityHot()
            for(let i=0;i<this.activityHot;i++){
                this.imgs[i] = this.activityHot[i].img
            }
            this.places=Base_api.getPlaces()
            function obj() {
                let value
            }
            for(let i=0;i<this.places.length;i++){
                let t = new obj()
                t.value = this.places[i].place
                this.options[i] = t
            }
            // alert(JSON.stringify(this.options))
        },
        open() {
            this.$alert('请先登录', '系统提示', {
                confirmButtonText: '确定',
                callback: action => {
                    this.$message({
                        type: 'warning',
                        message: '即将跳转到登录界面...'
                    });
                    location.href='./login.html'
                }
            });
        },
    },
    mounted(){
        if(sessionStorage.getItem("zh")==null){
            this.tag = false
            location.href='./login.html'
        }else {
            this.info()
            this.types=Base_api.getTypes()

        }
    }
})